#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
struct person
{
	int arr[205];
	int m;
	int score;
}A, B;
void judge(int a, int b)
{
	if (a == b)return;
	if (a == 0 && (b == 1 || b == 4)) {
		B.score++;
		return;
	}
	if (a == 0 && (b == 2 || b == 3)) {
		A.score++;
		return;
	}
	if (a == 1 && (b == 2 || b == 4)) {
		B.score++;
		return;
	}
	if (a == 1 && (b == 3 || b == 0)) {
		A.score++;
		return;
	}
	if (a == 2 && (b == 3 || b == 0)) {
		B.score++;
		return;
	}
	if (a == 2 && (b == 4 || b == 1)) {
		A.score++;
		return;
	}
	if (a == 3 && (b == 4 || b == 2)) {
		A.score++;
		return;
	}
	if (a == 3 && (b == 0 || b == 1)) {
		B.score++;
		return;
	}
	if (a == 4 && (b == 0 || b == 1)) {
		A.score++;
		return;
	}
	if (a == 4 && (b == 2 || b == 3)) {
		B.score++;
		return;
	}
}
int main()
{
	int N, NA, NB;
	cin >> N >> NA >> NB;
	int i = 0;
	for (i = 0; i < NA; i++) 
		scanf("%d", &(A.arr[i]));
	for (i = 0; i < NB; i++)
		scanf("%d", &(B.arr[i]));
	for (i = 0; i < N; i++) {
		judge(A.arr[A.m], B.arr[B.m]);
		A.m = ++A.m % NA;
		B.m = ++B.m % NB;
	}
	cout << A.score << ' ' << B.score;
	return 0;
}